<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>{:isset($info['id'])?'编辑':'新增'}分类</h2>
	</div>
    
<div class="panel panel-default">
	<!-- 标签页导航 -->
    <div class="tab-wrap panel-body">
        <ul class="nav nav-tabs ">    
			<li data-tab="tab1" class="active"><a href="#tab1" data-toggle="tab" >基 础</a></li>
			<li data-tab="tab2"><a href="#tab2" data-toggle="tab">高 级</a></li>  
        </ul>
        <div class="row">
            <div class="col-lg-6">              
        <!-- 表单 -->     
        <form action="{:U()}" method="post" class="form doc-modal-form" role="form" >
        <div class="tab-content panel-body">
            <!-- 基础 -->
            <div class="tab-pane fade in active" id="tab1">
					<div class="form-group">
						<label class="item-label">上级分类<span class="check-tips"></span></label> 
                        <input type="text" class="form-control" disabled="disabled" value="{$category['title']|default='无'}"/> 
					</div>
					<div class="form-group">
						<label class="item-label">
							分类名称<span class="check-tips">（名称不能为空）</span>
						</label> 
                        <input type="text" name="title" class="form-control" value="{$info.title|default=''}">		 
					</div>
					<div class="form-group">
						<label class="item-label">
							分类标识<span class="check-tips">（英文字母）</span>
						</label>					 
                        <input type="text" name="name" class="form-control" value="{$info.name|default=''}">				 
					</div>
					<div class="form-group">
						<label class="item-label">
							发布内容<span class="check-tips">（是否允许发布内容）</span>
						</label>
                        <div class="radio">
                            <label><input type="radio" name="allow_publish" id="allow_publish" value="0"  >不允许</label> 
                        </div>
                        <div class="radio"> 
                            <label><input type="radio" name="allow_publish" id="allow_publish" value="1" checked>仅允许后台</label>     
                        </div>
                        <div class="radio"> 
                            <label><input type="radio" name="allow_publish" id="allow_publish" value="2"  >允许前后台</label>  
                        </div>
					</div>
					<div class="form-group">
						<label class="item-label">
							是否审核<span class="check-tips">（在该分类下发布的内容是否需要审核）</span>
						</label>
                        <div class="radio">
                            <label><input type="radio" name="check" id="check" value="0"  >不需要</label> 
                        </div>
                        <div class="radio"> 
                            <label><input type="radio" name="check" id="check" value="1" checked>需要</label>     
                        </div>
					</div>
					<div class="form-group">
						<label class="item-label">绑定文档模型<span class="check-tips">（分类支持发布的文档模型）</span></label>			 
                        <volist name=":get_document_model()" id="list">
                            <label class="checkbox">
                                <input type="checkbox" name="model[]" value="{$list.id}">{$list.title}
                            </label>
                        </volist>				 
					</div>
					<div class="form-group">
						<label class="item-label">允许文档类型</label>			 
                        <volist name=":C('DOCUMENT_MODEL_TYPE')" id="type">
                            <label class="checkbox">
                                <input type="checkbox" name="type[]" value="{$key}">{$type}
                            </label>
                        </volist>				 
					</div>
					<div class="form-group">
						<label class="item-label">分类图标</label>
						<input type="file" id="upload_picture" class="btn btn-default btn-default">
						<input type="hidden" name="icon" id="icon" value="{$info['icon']|default=''}"/>
						<div class="upload-img-box">
						<notempty name="info['icon']">
							<div class="upload-pre-item"><img src="__ROOT__{$info.icon|get_cover='path'}"/></div>
						</notempty>
						</div>
					</div>
                    
					<script type="text/javascript">
					//上传图片
				    /* 初始化上传插件 */
					$("#upload_picture").uploadify({
				        "height"          : 30,
				        "swf"             : "__STATIC__/uploadify/uploadify.swf",
				        "fileObjName"     : "download",
				        "buttonText"      : "上传图片",
				        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
				        "width"           : 120,
				        'removeTimeout'	  : 1,
				        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
				        "onUploadSuccess" : uploadPicture,
				        'onFallback' : function() {
				            alert('未检测到兼容版本的Flash.');
				        }
				    });
					function uploadPicture(file, data){
				    	var data = $.parseJSON(data);
				    	var src = '';
				        if(data.status){
				        	$("#icon").val(data.id);
				        	src = data.url || '__ROOT__' + data.path;
				        	$("#icon").parent().find('.upload-img-box').html(
				        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
				        	);
				        } else {
				        	updateAlert(data.info);
				        	setTimeout(function(){
				                //$('#top-alert').find('button').click();
				                $(that).removeClass('disabled').prop('disabled',false);
				            },1500);
				        }
				    }
					</script>
				</div>
                
                <!-- 高级 -->
				<div id="tab2" class="tab-pane  fade tab2">
					<div class="form-group">
						<label class="item-label">网页标题</label>
 
							<input type="text" name="meta_title" class="form-control" value="{$info.meta_title|default=''}">
	 
					</div>
					<div class="form-group">
						<label class="item-label">关键字</label>
				 
 
								<textarea name="keywords" class="form-control" >{$info.keywords|default=''}</textarea>
	 
				 
					</div>
					<div class="form-group">
						<label class="item-label">描述</label>
					 
			 
								<textarea name="description" class="form-control" >{$info.description|default=''}</textarea>
	 
					 
					</div>
					<div class="form-group">
						<label class="item-label">频道模板</label>
					 
							<input type="text" name="template_index" class="form-control" value="{$info.template_index|default=''}">
				 
					</div>
					<div class="form-group">
						<label class="item-label">列表模板</label>
				 
							<input type="text" name="template_lists" class="form-control" value="{$info.template_lists|default=''}">
				 
					</div>
					<div class="form-group">
						<label class="item-label">详情模板</label>
					 
							<input type="text" name="template_detail" class="form-control" value="{$info.template_detail|default=''}">
					 
					</div>
					<div class="form-group">
						<label class="item-label">编辑模板</label>
				 
							<input type="text" name="template_edit" class="form-control" value="{$info.template_edit|default=''}">
			 
					</div>
				</div>
                
                
                
				<div class="form-group">
					<input type="hidden" name="id" value="{$info.id|default=''}">
					<input type="hidden" name="pid" value="{:isset($category['id'])?$category['id']:$info['pid']}">
					<button type="submit" id="submit" class="btn btn-default submit-btn ajax-post" target-form="form">确 定</button>
					<button class="btn btn-default btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                </div>
            </div>  
        </div>
        </form>	
            </div><!--  /div class="col-lg-6" -->
        </div><!-- /row -->
    </div>
    </div><!-- /panel-body -->
</block>

<block name="script">
	<script type="text/javascript">
		<present name="info.id">
		Think.setValue("allow_publish", {$info.allow_publish|default=1});
		Think.setValue("check", {$info.check|default=0});
		Think.setValue("model[]", {$info.model|json_encode} || [1]);
		Think.setValue("type[]", {$info.type|json_encode} || [2]);
		Think.setValue("display", {$info.display|default=1});
		Think.setValue("reply", {$info.reply|default=0});
		Think.setValue("reply_model[]", {$info.reply_model|json_encode} || [1]);
		</present>
		$(function(){
			showTab();
			$("input[name=reply]").change(function(){
				var $reply = $(".form-item.reply");
				parseInt(this.value) ? $reply.show() : $reply.hide();
			}).filter(":checked").change();
		});
		//导航高亮
		highlight_subnav('{:U('Category/index')}');
	</script>
</block>
